<template>
  <div>
    <van-nav-bar
        title="维修申报"
    />
    <van-field
        v-model="maintenanceRecord.classroomCode"
        label="教室"
        placeholder="请输入教室名称" />
    <van-field
        v-model="maintenanceRecord.applicant"
        label="故障设备"
        placeholder="请输入故障设备编号" />
    <van-field
        v-model="maintenanceRecord.description"
        label="故障描述"
        placeholder="请输入故障描述" />
    <div style="margin: 16px;">
      <van-button round block type="info" @click="onSubmit" :disabled=submitButtonDisabled>提交</van-button>
    </div>
  </div>
</template>

<script>

import {Toast} from "vant";
import {createMaintenanceRecord} from "../../api/maintenanceRecord";

export default {
  name: "Form",
  data() {
    return {
      maintenanceRecord: {
      },
      submitButtonDisabled: false
    };
  },
  methods: {
    onSubmit() {
      createMaintenanceRecord({
        classroomCode: this.maintenanceRecord.classroomCode,
        faultDescription: this.maintenanceRecord.description,
        applicant:this.maintenanceRecord.applicant,
      }).then((response) => {
        if(response.data.code === 200) {
          Toast.success('提交成功');
          this.submitButtonDisabled = true
        }
      })
    }
  },
}
</script>

<style scoped>

</style>